package worker;

import java.io.Serializable;

public class WorkerData implements Serializable{
	private String startTime 		= "N/A";
	private String endTime   		= "N/A";
	private String workerStatus 		= "Starting...";
	private int numberOfTasksProcessed = 0;
	private double averageTimePerTask  = 0.0;
	private double lastTaskTime        = 0.0;
	private double totalTimeSpentFarming = 0.0;
	private String workerAddress 				= "N/A";
	private int workerPort 					= 0;
	private boolean running 					= false;
	private int connectionCount			    = 0;
	private int id;
	private int mainWorkerID; //if multiple cores, the all hava a main and unique ID
	private int numberOfProcessors			=1; 
	private String operatingSystem				= "N/A";
	
	
	public int getMainWorkerID() {
		return mainWorkerID;
	}

	public void setMainWorkerID(int mainWorkerID) {
		this.mainWorkerID = mainWorkerID;
	}

	public String getStartTime() {
		return startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public String getSlaveStatus() {
		return workerStatus;
	}

	public int getNumberOfTasksProcessed() {
		return numberOfTasksProcessed;
	}

	public double getAverageTimePerTask() {
		 this.averageTimePerTask = this.totalTimeSpentFarming / this.numberOfTasksProcessed;
		return averageTimePerTask;
	}

	public double getLastTaskTime() {
		return lastTaskTime;
	}

	public double getTotalTimeSpentFarming() {
		return totalTimeSpentFarming;
	}

	public String getWorkerAddress() {
		return workerAddress;
	}

	public int getWorkerPort() {
		return workerPort;
	}

	public boolean isRunning() {
		return running;
	}

	public int getConnectionCount() {
		return connectionCount;
	}

	public int getId() {
		return id;
	}

	public int getNumberOfProcessors() {
		return numberOfProcessors;
	}

	public String getOperatingSystem() {
		return operatingSystem;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public void setWorkerStatus(String workerStatus) {
		this.workerStatus = workerStatus;
	}

	public void setNumberOfTasksProcessed() {
		this.numberOfTasksProcessed++;
	}


	public void setLastTaskTime(double lastTaskTime) {
		this.lastTaskTime = lastTaskTime;
	}

	public void setTotalTimeSpentFarming(double totalTimeSpentFarming) {
		getAverageTimePerTask(); // update
		this.totalTimeSpentFarming += totalTimeSpentFarming;
	}

	public void setWorkerAddress(String slaveAddress) {
		this.workerAddress = slaveAddress;
	}

	public void setWorkerPort(int slavePort) {
		this.workerPort = slavePort;
	}

	public void setRunning(boolean running) {
		this.running = running;
	}

	public void setConnectionCount(int connectionCount) {
		this.connectionCount = connectionCount;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setNumberOfProcessors(int numberOfProcessors) {
		this.numberOfProcessors = numberOfProcessors;
	}

	public void setOperatingSystem(String operatingSystem) {
		this.operatingSystem = operatingSystem;
	}

	@Override
	public String toString() {
		return "SlaveData [startTime=" + startTime + ", endTime=" + endTime
				+ ", slaveStatus=" + workerStatus + ", numberOfTasksProcessed="
				+ numberOfTasksProcessed + ", averageTimePerTask="
				+ averageTimePerTask + ", lastTaskTime=" + lastTaskTime
				+ ", totalTimeSpentFarming=" + totalTimeSpentFarming
				+ ", slaveAddress=" + workerAddress + ", slavePort=" + workerPort
				+ ", running=" + running + ", connectionCount="
				+ connectionCount + ", id=" + id + ", mainWorkerID="
				+ mainWorkerID + ", numberOfProcessors=" + numberOfProcessors
				+ ", operatingSystem=" + operatingSystem + "]";
	}

	
}